package kr.co.exight.onApp;

import library.Library;
import library.Variables;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class ActivityCardDetail extends Activity {

	/** Called when the activity is first created. */
	public static JSONObject data;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//arrCompanyInfo = ActivityTabOncard.getArrayData();
		setContentView(R.layout.act_carddetail);

		 
	    TextView tvCategory = (TextView)findViewById(R.id.cardDetail_tvCategory);
	    TextView tvName = (TextView)findViewById(R.id.cardDetail_tvName);
	    
	    TextView tvLocation = (TextView)findViewById(R.id.cardDetail_tvLocation);
	    TextView tvDiscount = (TextView)findViewById(R.id.cardDetail_tvDiscount);
	    TextView tvNote = (TextView)findViewById(R.id.cardDetail_tvNote);
	    
	    
	    Library.setFontNanumGothic(tvName);
	    Library.setFontNanumGothic(tvCategory);
	    
	    Library.setFontNanumGothic(tvLocation);
	    Library.setFontNanumGothic(tvDiscount);
	    Library.setFontNanumGothic(tvNote);
	    
	    
	    Library.setTextViewBold(tvName);
	    Library.setTextViewBold(tvCategory);
	    
	    
/*	    TextView tvIntroduce = (TextView)findViewById(R.id.cardDetail_tvIntroduce);
	    TextView tvSale = (TextView)findViewById(R.id.cardDetail_tvSale);
	    TextView tvDescript = (TextView)findViewById(R.id.cardDetail_tvEtc);*/
	    Button btnMap = (Button)findViewById(R.id.cardDetail_btnMap);
	    
		
		/* TextView tvIntroduce = (TextView)findViewById(R.id.cardDetail_tvIntroduce);
	    TextView tvSale = (TextView)findViewById(R.id.cardDetail_tvSale);
	    TextView tvDescript = (TextView)findViewById(R.id.cardDetail_tvEtc);*/


		Button btnSale = (Button)findViewById(R.id.cardDetail_btnSale);

		btnMap.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub

				Intent i = new Intent(ActivityCardDetail.this, ActivityTabOncard.class);
				try {
					i.putExtra("long", data.getJSONObject("position").getDouble("longitude"));
					i.putExtra("lati", data.getJSONObject("position").getDouble("longitude"));
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				startActivity(i);
			}
		});
		
		 btnSale.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					// TODO Auto-generated method stub
					Intent i = new Intent(ActivityCardDetail.this, ActivityCard.class);
					startActivity(i);
				}
		});
		 
		  try{
		    	tvCategory.setText("");
		    	
		    	tvName.setText(data.getString("name"));
		 	    
		    	
		    	tvLocation.setText(data.getString("address"));
				
		    	if(!data.isNull("discount"))
		    		tvDiscount.setText(data.getString("discount"));
		    	
		    	if(!data.isNull("note"))
		    		tvNote.setText(data.getString("note"));
		    	
		    	/*tvIntroduce.setText("준비 중입니다.");
				tvSale.setText("준비 중입니다.");
				tvDescript.setText("준비 중입니다.");*/
				
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

	}

	public static void setJSONData(JSONObject _data){
		data = _data;
	}

}
